package DesignPattern.Link;

/**
 * 责任链模式
 */
public abstract class Approver {
    //下一个调用者
    Approver next ;
    //需要传入的名字
    String name ;

    public Approver(String name){
        this.name = name;
    }

    //设置下一个调用者
    public void setNext(Approver next) {
        this.next = next;
    }

    public abstract void processApprover(ApproverRequest approveRequest);
}

class Test {
    public static void main(String[] args) {
        //创建一个请求
        ApproverRequest approveRequest = new ApproverRequest(1, 31000, 1);
        //创建相关的审批人
        TeacherApprover teacherApprover = new TeacherApprover("张老师");
        CollegeApprover collegeApprover = new CollegeApprover("李院长");
        SchoolMasterApprover schoolMasterApprover = new SchoolMasterApprover("佟校长");

        //需要将各个审批级别的下一个设置好
        teacherApprover.setNext(collegeApprover);
        collegeApprover.setNext(schoolMasterApprover);

        //单向责任链这里可以不加
        teacherApprover.processApprover(approveRequest);
    }
}
